<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Admin/Public/css/common.css">
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<link href="__PUBLIC__/Admin/css/bootstrap-datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">到货通知列表</h1>
            </div>
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">

                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="dataTable_wrapper">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <include file="Extends/searchForUser"/>
                                <thead>
                                <tr>
                                    <th style="text-align:center"><input name="all_checkbox" type='checkbox'
                                                                         id="all_checkbox"></th>
                                    <th class="text-center GridSortTh" width="11%" data-order="b_ISBN">条形码</th>
                                    <th style="text-align:center">图片</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="b_TITLE"
                                        width="250px">书名
                                    </th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="b_AUTHOR">作者</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="b_PRESS">出版社</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="b_PACKING_SPECIFICATION">包装</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="b_Y_PRICE">定价</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="b_STOCK">库存</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="tz_CREATETIME">点击时间</th>
                                    <th style="text-align:center" class="text-center GridSortTh" data-order="tz_OPENID">通知用户</th>
                                    <th style="text-align:center" width="10%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <foreach name="data" item="v">
                                    <tr>
                                        <td><input type='checkbox' name='checkbox'></td>
                                        <td><a target='_blank' href="{:U('Book/EditBookIndex')}?ID={$v.b_ID}">
                                            <span class="text-danger">{$v.b_ISBN}</span></a><br/>
                                        </td>
                                        <td><img width="80px" src="{$v.b_PIC_URL}"></td>
                                        <td>{$v.b_TITLE}</td>
                                        <td>{$v.b_AUTHOR}</td>
                                        <td>{$v.b_PRESS}</td>
                                        <td>{$v.b_PACKING_SPECIFICATION}</td>
                                        <td>{$v.b_Y_PRICE}</td>
                                        <td>{$v.b_STOCK}</td>
                                        <td>{$v.tz_CREATETIME}</td>
                                        <td><a target="_blank" href="{:U('User/Index')}?user_id={$v.tz_OPENID}"> <span class="text-danger">{$v.tz_OPENID}</span></a></td>
                                        <td>
                                            <if condition="$v.b_STOCK gt 0">
                                                <span class="btn btn-danger btn-xs" onclick='BookTZ("{$v.tz_ID}",$(this))'>用户通知</span>
                                                <else/>
                                                <span class="btn btn-warning btn-xs">暂无库存</span>
                                            </if>
                                        </td>
                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                            <div class="blue">{$show}</div>
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
    </div>
    <!-- /#page-wrapper -->
</div>
<include file="CommonSidebar:common-script"/>
<script src="__PUBLIC__/Admin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__PUBLIC__/Admin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
<script src="__PUBLIC__/Common/grid.js"></script>
<script src="__PUBLIC__/Admin/js/bootstrap-datetimepicker.js"></script>
<script src="__PUBLIC__/Admin/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>

<script type="text/javascript">
    $('#dataTables-example').grid();
</script>

<script>

    <!--全选择框-->
    $("#all_checkbox").click(function () {
        if ($(this).is(':checked')) {
            $("input[name='checkbox']").prop("checked", "true");
        } else {
            $("input[name='checkbox']").removeAttr("checked", false);

        }
    });
    //到货通知接口
    function BookTZ(ID, $elem) {
        if (confirm("确认通知用户？")) {
            $.post("{:U('BookTZ')}",
                    {ID: ID},
                    function (data) {
                        console.log(data);
                        if (parseInt(data) > 0) {
                            $elem.parent().parent().remove();
                            alert('通知成功');
                        } else {
                            alert('通知失败');
                        }
                    });
        }
    }


</script>
</body>
</html>
